package top.zhaoyuliu.logbook.server.connect.server;

import java.io.IOException;

import org.tio.server.ServerGroupContext;
import org.tio.server.TioServer;
import org.tio.server.intf.ServerAioHandler;
import org.tio.server.intf.ServerAioListener;

import top.zhaoyuliu.logbook.server.properties.LbServiceProperties;

/**
 * 
 * Copyright © 2021 Arain. All rights reserved.
 *
 * @Title: LbServerStarter.java
 * @Prject: logbook-server
 * @Package: top.zhaoyuliu.logbook.server.connect.server
 * @Description: <功能详细描述>
 * @author: Arain
 * @date: 2021年1月22日 下午4:55:53
 * @version: V1.0
 */
public class LbServerStarter {

	private LbServiceProperties lbServiceProperties;

	public LbServerStarter(LbServiceProperties lbServiceProperties) {
		super();
		this.lbServiceProperties = lbServiceProperties;
	}

	public void start() throws IOException {
		ServerAioHandler serverAioHandler = new LbServerAioHandler();
		ServerAioListener serverAioListener = new LbServerAioListener();
		ServerGroupContext serverGroupContext = new ServerGroupContext(serverAioHandler, serverAioListener);
		TioServer aioServer = new TioServer(serverGroupContext);
		// 本机启动服务
		aioServer.start(null, lbServiceProperties.getPort());
	}
}
